#define _CRT_SECURE_NO_WARNINGS

#include"string.h"

void test1()
{
	cx::string s1("abcdefg");
	cout << s1.c_str() << endl;

	cx::string s2(s1);
	cout << s2.c_str() << endl;

	cx::string s3 = s1;
	cout << s3.c_str() << endl;

	for (auto e : s3)
	{
		cout << e << ' ';
	}
	cout << endl;

	for (size_t i = 0; i < s3.size(); ++i)
	{
		cout << s3[i] << ' ';
	}
	cout << endl;

	cout << s3.size() << endl;
	cout << s3.capacity() << endl;

	s3.reserve(100);
	cout << s3.size() << endl;
	cout << s3.capacity() << endl;


}

void test2()
{
	cx::string s1("abcdefg");
	cout << s1.c_str() << endl;

	cx::string s2(s1);
	cout << s2.c_str() << endl;

	cx::string s3 = s1;
	cout << s3.c_str() << endl;

	s1.push_back('c');
	for (auto e : s1)
	{
		cout << e;
	}
	cout << endl;
	cout << s1.size() << endl;
	cout << s1.capacity() << endl;

	s1.append("xxxxx");
	for (auto e : s1)
	{
		cout << e;
	}
	cout << endl;
	cout << s1.size() << endl;
	cout << s1.capacity() << endl;


}


void test3()
{
	cx::string s1("abcdefg");
	cout << s1.c_str() << endl;

	

	s1.append("xxxxx");
	for (auto e : s1)
	{
		cout << e;
	}
	cout << endl;
	cout << s1.size() << endl;
	cout << s1.capacity() << endl;

	s1.push_back('c');
	for (auto e : s1)
	{
		cout << e;
	}
	cout << endl;
	cout << s1.size() << endl;
	cout << s1.capacity() << endl;


	s1.append("xxxxx");
	for (auto e : s1)
	{
		cout << e;
	}
	cout << endl;
	cout << s1.size() << endl;
	cout << s1.capacity() << endl;
	 
	cx::string s4(10, 'c');
	for (auto e : s4)
	{
		cout << e;
	}
	cout << endl;
	cout << s4.size() << endl;
	cout << s4.capacity() << endl;

}

void test4()
{
	cx::string s1("abcdefg");
	cout << s1.c_str() << endl;

	s1.insert(3, '5');
	cout << s1.c_str() << endl;
	s1.insert(8, '5');
	cout << s1.c_str() << endl;
	s1.insert(0, '5');
	cout << s1.c_str() << endl;

	s1.insert(3, "4444");
	cout << s1.c_str() << endl;

	s1.erase(3, 2);
	cout << s1.c_str() << endl;

}


void test5()
{
	cx::string s1("abcdefg");
	cout << s1.c_str() << endl;

	cout << s1.find('x') << endl;
	cout << s1.find('a') << endl;
	cout << s1.find('a', 5) << endl;

	cout << s1.find("def", 2) << endl;
	cout << s1.find("cccf", 2) << endl;


}


void test6()
{
	cx::string s1("abcdefg");
	cout << s1.c_str() << endl;

	cx::string s2("xxxxxxxxx");
	cout << s2.c_str() << endl;

	s1.swap(s2);
	cout << s1.c_str() << endl;
	cout << s2.c_str() << endl;

	cx::string s3 = s1.substr(3, 5);
	cout << s3.c_str() << endl;

	cout << (s1 < s2) << endl;
	cout << (s1 <= s2) << endl;
	cout << (s1 > s2) << endl;
	cout << (s1 >= s2) << endl;
	cout << (s1 == s2) << endl;
	cout << (s1 != s2) << endl;
	cout << strcmp("a", "b") << endl;

}

void test7()
{
	cx::string s1("abcdefg");
	cout << s1.c_str() << endl;

	cin >> s1;
	cout << s1 << endl;
}

void test8()
{
	cx::string s1("abcdefg");
	cout << s1.c_str() << endl;

	cx::string s2(s1);
	cout << s2.c_str() << endl;

	cx::string s3;
	s3 = s1;
	cout << s3.c_str() << endl;


}


int main()
{
	//test1();
	//test2();
	//test3();
	//test4();
	//test5();
	//test6();
	//test7();
	test8();

	return 0;
}